/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Formularios;

import BD.Caixa_relatorio;
import BD.utilsPim;
import java.util.ArrayList;
import org.eclipse.persistence.internal.libraries.asm.Opcodes;

/**
 *
 * @author CORE
 */
public class FormRelatorioCaixa extends javax.swing.JDialog {

    /**
     * Creates new form FormRelatorioCaixa
     */
    public FormRelatorioCaixa(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        gerarRelatorio();
        setLocationRelativeTo(null);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        list1 = new java.awt.List();
        list = new java.awt.List();
        listvalor = new java.awt.List();
        jtabertura = new com.toedter.calendar.JDateChooser();

        list1.setFont(new java.awt.Font("Dialog", 0, 24)); // NOI18N
        list1.setName(""); // NOI18N

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Master Pizza - Relatorio de Caixa");

        listvalor.setFont(new java.awt.Font("Courier New", 0, 18)); // NOI18N
        listvalor.setMultipleMode(true);
        listvalor.setName(""); // NOI18N

        jtabertura.setToolTipText("");
        jtabertura.setDateFormatString("dd/MM/yyyy HH:mm:ss");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(list, javax.swing.GroupLayout.PREFERRED_SIZE, 359, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(listvalor, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtabertura, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(list, javax.swing.GroupLayout.DEFAULT_SIZE, 359, Short.MAX_VALUE)
            .addComponent(listvalor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jtabertura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    
    private void gerarRelatorio(){
        Caixa_relatorio cxr = new Caixa_relatorio();
        ArrayList<Caixa_relatorio> ltcxr =new ArrayList<Caixa_relatorio>();
        utilsPim utl = new utilsPim();
        ltcxr = cxr.getItens();

        String lin1 = "-------------------------------------------------------";
        String lin2 = "--------------------------------";
        
        list.setFont(listvalor.getFont());               
        list.add("Data Hora Abertura");
        jtabertura.setDate(ltcxr.get(0).getDtabertura());
        listvalor.add(utl.getDateHoraChooser(jtabertura));
        list.add("Data Hora Fechamento");       
        jtabertura.setDate(ltcxr.get(0).getDtfechamento());
        listvalor.add(utl.getDateHoraChooser(jtabertura));        
        list.add(lin1);
        list.add("Agrupado por Tipo de pagamento");
        list.add(lin1);
        listvalor.add(lin2);
        listvalor.add("Valor");
        listvalor.add(lin2);
       
        for (int i = 0; i < ltcxr.size(); i++) {
            list.add(ltcxr.get(i).getTipopgto());
            listvalor.add(utl.formatavalor(ltcxr.get(i).getValor()));            
        }
        
        list.add("");
        listvalor.add("");
        list.add(lin1);
        listvalor.add(lin2);
        list.add("TOTALIZAÇÃO");
        listvalor.add("Valor");
        list.add(lin1);
        listvalor.add(lin2);
        list.add("Saldo inicial");        
        listvalor.add(utl.formatavalor(ltcxr.get(0).getSaldo_inicial()));
        list.add("Total de venda");        
        listvalor.add(utl.formatavalor(ltcxr.get(0).getTotal()));
        list.add("Total Geral--------------------------------->>>>>>");        
        listvalor.add(utl.formatavalor(ltcxr.get(0).getTotal_geral()));    
        
    }           
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FormRelatorioCaixa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FormRelatorioCaixa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FormRelatorioCaixa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FormRelatorioCaixa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                FormRelatorioCaixa dialog = new FormRelatorioCaixa(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private com.toedter.calendar.JDateChooser jtabertura;
    private java.awt.List list;
    private java.awt.List list1;
    private java.awt.List listvalor;
    // End of variables declaration//GEN-END:variables
}
